public class MarketSubcategoriesPanel : MarketPanel
{
	public static MarketSubcategoriesPanel instance;

	public int normalButtonWight = 110;

	public int smallButtonWight = 95;

	public override void Awake()
	{
		base.Awake();
		instance = this;
	}

	public override void InitButtons()
	{
		base.InitButtons();
		float width = normalButtonWight;
		buttonsGrid.cellWidth = normalButtonWight;
		if ((MarketControllerUI.instance.categoriesPanel.selected == "Best" && marketControllerUI.iPad) || marketControllerUI.columnsCount < 3)
		{
			width = smallButtonWight;
			buttonsGrid.cellWidth = smallButtonWight;
		}
		int num = 0;
		foreach (string subCategory in MarketController.Instance.ProductHierarchy.marketCategories.Find((MarketProductsHierarchy.MarketCategory c) => c.name.Equals(marketControllerUI.selectedCategory)).subCategories)
		{
			if (!subCategory.Equals("Hidden"))
			{
				SetButton(subCategory, num, width);
				num++;
			}
		}
		buttonsGrid.repositionNow = true;
		AnimateButtons();
	}

	public void AnimateButtons()
	{
		foreach (MarketButton panelButton in panelButtons)
		{
			if ((bool)panelButton.uiAnimation)
			{
				panelButton.holder.alpha = 0f;
				panelButton.uiAnimation.Play();
			}
		}
	}

	public override void Select(string item, bool selectDefault = true)
	{
		if (!string.IsNullOrEmpty(marketControllerUI.selectedCategory) && !string.IsNullOrEmpty(item) && !selected.Equals(item))
		{
			base.Select(item);
			if (MarketControllerUI.instance.categoriesPanel.selected == "Best")
			{
				MarketControllerUI.instance.SetMarketWidth(selected == "Rides");
			}
			if (selectDefault)
			{
				marketControllerUI.productsPanel.Unselect();
				marketControllerUI.productsPanel.InitButtons();
			}
		}
	}
}
